
#include "RtBase.h"
#include "RtThreadProxyManager.h"


//////////////////////////////////////////////////////////////////////
// class CRtThreadProxyBase
//////////////////////////////////////////////////////////////////////

CRtThreadProxyBase::CRtThreadProxyBase(CRtThreadManager::TType aType)
{
	m_pEventQueue = CRtThreadManager::Instance()->GetThreadEventQueue(aType);
	RT_ASSERTE(m_pEventQueue);
}

CRtThreadProxyBase::CRtThreadProxyBase(CRtThread *aThread)
{
	if (aThread)
		m_pEventQueue = aThread->GetEventQueue();
	else
		m_pEventQueue = NULL;
	RT_ASSERTE(m_pEventQueue);
}

CRtThreadProxyBase::~CRtThreadProxyBase()
{
}

RtResult CRtThreadProxyBase::PostEvent_i(IRtEvent* aEvent)
{
	if (!aEvent)
		return RT_ERROR_INVALID_ARG;
	else if (m_pEventQueue)
		return m_pEventQueue->PostEvent(aEvent);
	else
		return RT_ERROR_UNEXPECTED;
}

RtResult CRtThreadProxyBase::SendEvent_i(IRtEvent* aEvent)
{
	if (!aEvent)
		return RT_ERROR_INVALID_ARG;
	else if (m_pEventQueue)
		return m_pEventQueue->SendEvent(aEvent);
	else
		return RT_ERROR_UNEXPECTED;
}

//////////////////////////////////////////////////////////////////////
// class CRtThreadProxyManager
//////////////////////////////////////////////////////////////////////

CRtThreadProxyManager::CRtThreadProxyManager()
{

}

CRtThreadProxyManager::~CRtThreadProxyManager()
{

}
